<template>
  <ul class="contact-container">
    <li v-for="(item, index) in contacts" :key="index">
      <a :href="item.target !== '' ? item.target : '#'">
        <div class="icon">
          <Icon :type="item.icon"></Icon>
        </div>
        <p class="txt">{{ item.id }}</p>
      </a>
      <div class="pop">
        <img :src="item.url" alt="">
      </div>
    </li>
  </ul>
</template>

<script>
import "@/styles/global.less"
import Icon from '@/components/Icon'
export default {
  components: {
    Icon
  },
  props: {
  },
  data() {
    return {
      contacts: [
        {
          id: 'RPK_16',
          url: "http://localhost:4000/static/image/qrcode_gitee.com.png",
          icon: 'gitee',
          target: 'https://gitee.com/rpk16'
        },
        {
          id: 'RPK16V',
          url: "http://localhost:4000/static/image/qrcode_juejin.cn.png",
          icon: 'juejin',
          target: 'https://juejin.cn/user/1898237492996489/posts'
        },
        {
          id: 'RPK16V',
          url: "http://localhost:4000/static/image/qrcode_github.com.png",
          icon: 'github',
          target: 'https://github.com/RPK16V'
        },
        {
          id: '331140187',
          url: "http://localhost:4000/static/image/qrcode_qq.png",
          icon: 'qq',
          target: ''
        }
      ]
    }
  }
}
</script>

<style lang="less" scoped>

@import "~@/styles/mixin.less";
@import "~@/styles/var.less";
.contact-container {
  width: 100%;
  height: 100%;
  list-style: none;
  padding: 0;
  margin: 0;
  color: @gray;
  @liheight: 25px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  li {
    height: @liheight;
    line-height: 25px;
    padding: 10px 0px;
    margin: 0 20px;
    position: relative;
    &:hover .pop {
        transform: scaleY(1);
    }
    &:hover a {
      color: #936de8;
    }
  }

  a {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 300ms ease-in-out;

    .icon {
      width: @liheight;
      height: @liheight;
      margin: 0;
      padding: 0;
      margin-left: 10px;
      font-size: 20px;
    }
    .txt {
      padding-left: 20px;
    }
  }

  .pop {
    width: 150px;
    height: 150px;
    // 不明确宽高导致伪元素定位不准
    position: absolute;
    bottom: @liheight;
    left: 0;
    // 纵向变形
    transform: scaleY(0);
    transform-origin: center bottom;
    transition: all 300ms ease-in;
    
    img {
      border-radius: 6px;
      width: 100%;
      object-fit: cover;
    }
    &::after {
      content: '';
      margin: 0;
      padding: 0;
      position: absolute;
      left: 50%;
      bottom: 0;
      transform: translateX(-50%) translateY(50%) rotate(45deg);
      width: 9px;
      height: 9px;
      background: #ffffff;
    }
  }

}
</style>